home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
MacHack 1994
/
MacHack 1994.toast
/
MacHack™94
/
Talks & Papers
/
Timothy Knox
/
yerk 3.66
/
System source
/
String
< prev
next >
Wrap
Text File
|
1994-06-24
|
3KB
|
73 lines
\ String
\ 5/25/84 NDI Version 1
\ 10/13/84 CBD string: is now get:, added put:
\ Removed length:, curpos, works like Ordered-Col
\ 12/29/84 cbd Converted to heap-based string
\ 1/15/85 cbd Split into BasicStr, String
\ 7/23/85 cdn Fixed charOf: method; Added fill: method
\ Removed unused word ab0
\ 8/25/86 cdn Changed charOf: & indexOf: to leave current offset 1 byte later
\ 7/02/90 rfl fixed =: so that the source is locked during xfer
\ 9/27/90 rfl modified using getstate and setstate
\ 11/11/91 rfl simplified fill:
Decimal
\ String is a dynamic heap based string object that can grow and shrink
:CLASS String <Super BasicStr
\ ( -- offs ) return the current offset
:M WHERE: get: offset ;M
\ move to the 0th byte in the string
:M START: 0 moveTo: self ;M
\ assign this string to any object that accepts addr len
:M =: { destObj -- } getState: self lock: self get: self put: destObj setState: self ;M
\ use for concatenating the receiving object data to the end of the data
\ of the object on the stack
\ same as add: except that the thing on the stack is another handle
\ and the destination is on the stack.
:M CONCAT: { destObj -- } getState: self lock: self get: self add: destObj setState: self ;M
\ ( chr len -- ) clear the string and set it to len bytes of chr
:M FILL: setSize: self get: self rot Fill ;M
\ name an object using this string
:M NAME=: { destObj -- } getState: self lock: self get: self name: destObj setState: self ;M
\ ( len -- ) return the substring starting at offset
:M SUBSTR: { len -- addr len } get: offset 0< classErr" 151
ptr: self get: offset +
size: self get: offset - len min 0 max ;M
:M DELETE: { addr len -- } addr len addr 0 replace: self ;M
:M INDEXOF: { addr len -- offs } addr len 0 0 replace: self
get: offset dup 0<
IF drop false
ELSE true
THEN ;M
\ ( char -- offs t OR f ) find a single character in the string
:M CHAROF: pad c! pad 1 indexof: self ;M
\ ( ^fcb -- rc ) Fill string from file object
:M READ: { theFcb len -- rc } len setsize: self
get: self read: thefcb
bytesRead: thefcb setSize: self ;M
\ ( ^fcb -- rc ) Fill string from file object
:M READLINE: { theFcb len -- rc } len setSize: self
get: self readLine: thefcb
bytesRead: thefcb setSize: self ;M
\ ( rect just -- ) draw string justified in rect
:M DRAW: { tRect just -- } ptr: self +base size: self
tRect +base just makeInt $ a9ce trap ( call TextBox ) ;M
;CLASS
<" Files